<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
 <link href="${pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css"/>       
        <link href="${pageContext.request.contextPath}/assets/css/codemirror.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/ace.min.css" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/font/css/font-awesome.min.css" />
        <!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
		<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
        <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
		<script src="${pageContext.request.contextPath}/assets/js/typeahead-bs2.min.js"></script>           	
		<script src="${pageContext.request.contextPath}/assets/js/jquery.dataTables.min.js"></script>
		<script src="${pageContext.request.contextPath}/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script src="${pageContext.request.contextPath}/assets/layer/layer.js" type="text/javascript" ></script>          
        <script src="${pageContext.request.contextPath}/assets/laydate/laydate.js" type="text/javascript"></script>
<title>回复</title>

<script type="text/javascript">
		function submitForm()
		{
			document.getElementById("myForm").submit();
		}
		
		$(function(){
			
			 $("input[name='typeId']").click(function(){
		            $("#checkAll").prop("checked",$("input[name='typeId']").length == $("input[name='typeId']:checked").length ? true : false);
		        });
			
			$("#checkAll").click(
			  function(){
			   $("input[name='typeId']").prop("checked",this.checked);
			  }
			);
			
			/**批量删除**/
			$("#deleteByGroup").click(function(){
				var typeId="";
				if($("input[name='typeId']:checked").length)
					{
						layer.confirm('确认要删除吗？',function(index){
							$("input[name='typeId']:checked").each(function(){
								typeId=typeId+$(this).parents("tr").find(".type_id").html()+";";
							});
							$("#del_list").val(typeId);
							$("#delopr").val("del");
							//alert($("#del_list").val());
							//alert($("#delopr").val());
							$("#delForm").submit();
							layer.close(index);	
						});
					}
				else
					{
					layer.alert("你未选中任何项",{
			               title: '提示框',				
						icon:1,		
						  });				
					}
				//alert(typeId);
			});
		});
		
		function checkMsg()
		{
			if($("#updatereply").length>0)
			{
				  layer.alert($("#updatereply").html(),{
	               title: '提示框',				
				icon:1,		
				  });
			}
		}
		
		//${requestScope.opinion.customer.customer_name }
		//${requestScope.opinion.details }
	</script>


</head>

<body onload="checkMsg();">
<div class="margin clearfix">
 <div class="Guestbook_style">
     <div class="d_Confirm_Order_style">
    <div class="search_style">
      <div class="title_names">留言信息</div>
    	<div>留言用户:${sessionScope.opinion.customer.customer_name }
    	</div>
    	<br />
    	<div>
    		留言内容:${sessionScope.opinion.details }
    	</div>
    </div>
 
    <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:ovid()" class="btn btn-danger" id="deleteByGroup" ><i class="fa fa-trash"></i>&nbsp;批量删除</a>
       <a href="opinionServlet;" class="btn btn-sm btn-primary"><i class="fa fa-check"></i>&nbsp;返回上一层</a>
       </span>
       <span class="r_f">共：<b>${replylist.size() }</b>条</span>
     </div>
    <!--回复列表-->
    <div class="Guestbook_list">
      <table class="table table-striped table-bordered table-hover" id="sample-table">
      <thead>
		 <tr>
          <th width="25"><label><input type="checkbox" class="ace" id="checkAll" /><span class="lbl" ></span></label></th>
          <th width="80">ID</th>
          <th width="150px">回复人</th>
          <th width="">回复内容</th>
          <th width="200px">时间</th>
          <th width="70">状态</th>                
          <th width="250">操作</th>
          </tr>
      </thead>
	<tbody>
		 <c:if test="${replylist!= null && replylist.size() > 0}">
          	<c:forEach items="${replylist }" var="reply">
          	<tr>
     			<td><label><input type="checkbox" class="ace" name="typeId"  /><span class="lbl"></span></label></td>
         		<td class="type_id">${reply.reply_id }</td>
         		<td class="opinion_customer"><u style="cursor:pointer"  class="text-primary" onclick="member_show('张小泉','member-show.html','1031','500','400')">${reply.adminer.admin_name }</u></td>
          		<td class="text-l">${reply.details }</td>
          		<td>${reply.start_date }</td>
          		<td class="td-status"><span class="label label-success radius">未锁定</span></td>
         		<td class="td-manage">
           		<a onclick="member_stop(this,'10001')"  href="javascript:;" title="未锁定"  class="btn btn-xs btn-success"><i class="fa fa-check  bigger-120"></i></a>   
        		<a  href="javascript:;"  onclick="member_del(this)" title="删除" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>
          		</td>
        	</tr> 
          	</c:forEach>
         </c:if> 
        </tbody>
      </table>
    </div>
 </div>
</div>
	
<!--操作信息-->
<div style="display: none">
	<c:if test="${sessionScope.excuteMsg_reply!=null&&sessionScope.excuteMsg_reply.length()>0 }"><span id="updatereply">${sessionScope.excuteMsg_reply }</span></c:if>
</div>	
		
<!--批量删除提交-->
<div style="display: none">
	<form action="replyServlet" method="post" id="delForm">
		<input type="hidden" name="opr" id="delopr" />
		<input type="text" id="del_list" name="del_list" />
	</form>
</div>

<!--单个删除提交-->
<div style="display: none">
	<form action="replyServlet" method="post" id="delBySingle">
		<input type="hidden" name="opr" value="del" />
		<input type="hidden" name="reply_id" id="delsingleId" />
	</form>
</div>


</body>
</html>
<script type="text/javascript">
 /*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url+'#?='+id,w,h);
}
 
/*******删除单条回复*********/
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$("#delsingleId").val($(obj).parents("tr").find(".type_id").html());
		$("#delBySingle").submit();
		layer.close(index);	
	});
}

/*锁定*/
function member_stop(obj,id){
	layer.confirm('确认要锁定吗？',function(index){
		$(obj).parents("tr").find(".ace").prop("checked",false).attr("disabled","disabled");
		$(obj).next().remove();
		$(obj).after('<a title="删除" href="javascript:;"  class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="解锁"><i class="fa fa-check  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已锁定</span>');
		var $aa=$($(obj).parents("td"));
		$(obj).remove();
		//alert($aa.html());
		layer.msg('已锁定!',{icon: 5,time:1000});
	});
}
//<a title="编辑" onclick="member_edit('550')" href="javascript:;"  class="btn btn-xs btn-info" ><i class="icon-edit bigger-120"></i></a> 

/*解锁*/
function member_start(obj,id){
	layer.confirm('确认要解锁吗？',function(index){
		$(obj).parents("tr").find(".ace").removeAttr("disabled");
		$(obj).next().remove();
		$(obj).after(' <a title="删除" href="javascript:;"  onclick="member_del(this)" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="锁定"><i class="fa fa-check  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已解锁</span>');
		var $aa=$($(obj).parents("td"));
		$(obj).remove();
		//alert($aa.html());
		layer.msg('已解锁!',{icon: 6,time:1000});
	});
}

/*checkbox激发事件*/
$('#checkbox').on('click',function(){
	if($('input[name="checkbox"]').prop("checked")){
		 $('.Reply_style').css('display','block');
		}
	else{
		
		 $('.Reply_style').css('display','none');
		}	
	});

</script>
<script type="text/javascript">
jQuery(function($) {
var oTable1 = $('#sample-table').dataTable( {
"aaSorting": [[ 1, "desc" ]],//默认第几个排序
"bStateSave": true,//状态保存
"aoColumnDefs": [
  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
  {"orderable":false,"aTargets":[0,5,6]}// 制定列不参与排序
] } );
		$('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
				
		});	
		$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table')
			var off1 = $parent.offset();
			var w1 = $parent.width();
	
			var off2 = $source.offset();
			var w2 = $source.width();
	
			if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
			return 'left';
		}
	});
</script>
